package com.baizan.daka.mvp.model

import com.baizan.daka.util.SchedulerUtils
import com.hazz.kotlinmvp.net.BaseResponse
import com.hazz.kotlinmvp.net.RetrofitManager
import io.reactivex.Observable

class UserBankModel {
    fun modifyPassword(oldPassword: String, newPassword: String): Observable<BaseResponse<String>> {
        val map = HashMap<String, String>()
        map.put("bankCode", newPassword)
        map.put("oldBankCode", oldPassword)
        return RetrofitManager.service.updateBankCode(map)
            .compose(SchedulerUtils.ioToMain())
    }

    fun addPassword(newPassword: String): Observable<BaseResponse<String>> {
        val map = HashMap<String, String>()
        map.put("bankCode", newPassword)
        return RetrofitManager.service.addBankCode(map)
            .compose(SchedulerUtils.ioToMain())
    }

    fun getPassword(): Observable<BaseResponse<String>> {
        return RetrofitManager.service.getBankCode()
            .compose(SchedulerUtils.ioToMain())
    }
}
